#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n, m;
	cin >> n >> m;
	if (m >= n) {
		cout << 1;
		return 0;
	}
	int ans = 0;
	if (m % 2) {
		int a = 7 * m + 1;
		int leave = n - a;
		if (leave > 0) {
			int group = leave / 7;
			int le = leave % 7;
			ans = log2(3 * m + 1) + 2;
			ans += group * 3;
			if (le <= 4)	ans++;
			else if (le <= 6)	ans += 2;
			else  ans += 3;
		} else {
			ans = 1;
			int beg = 3 * m + 1;
			for (int i = 1; i <= 100; i++) {
				ans++;
				leave -= beg;
				beg /= 2;
				if (leave <= 0)
					break;
			}
		}
	} else {
		int a = 2 * m - 1;
		int leave = n - a;
		if (leave > 0) {
			int group = leave / 7;
			int le = leave % 7;
			ans = log2(m) + 1;
			ans += group * 3;
			if (le <= 4)	ans++;
			else if (le <= 6)	ans += 2;
			else  ans += 3;
		} else {
			ans = 0;
			for (int i = 1; i <= 100; i++) {	// log2(m)
				ans++;
				n -= m;
				m /= 2;
				if (n <= 0)
					break;
			}
		}
	}
	cout << ans;
	return 0;
}
